package com.twu.biblioteca;

public class User {

    private final int libraryNumber;
    private final String password;
    private final String name;
    private final String email;
    private final String phoneNumber;

    public User(int libraryNumber, String password, String name, String email, String phoneNumber) {

        this.libraryNumber = libraryNumber;
        this.password = password;
        this.name = name;
        this.email = email;
        this.phoneNumber = phoneNumber;
    }

    public User(int libraryNumber, String password) {

        this.libraryNumber = libraryNumber;
        this.password = password;
        this.name = null;
        this.email = null;
        this.phoneNumber = null;
    }

    public String toString() {
        return name + "\t" + email + "\t" + phoneNumber;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        User user = (User) o;

        if (libraryNumber != user.libraryNumber) {
            return false;
        }
        if (!password.equals(user.password)) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = libraryNumber;
        result = 31 * result + password.hashCode();
        return result;
    }
}
